import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:flutter_appdemo02/list/picture.dart';

class LoveAwesome extends StatefulWidget {
  @override
  _LoveAwesomeState createState() => _LoveAwesomeState();
}

class _LoveAwesomeState extends State<LoveAwesome> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.white,
        elevation: 0,
        leading: GestureDetector(
          child: Icon(
            Icons.arrow_back_ios,
            color: Colors.black,
          ),
          onTap: () {
            Navigator.of(context).pop();
          },
        ),
      ),
      body: CustomScrollView(
        shrinkWrap: true,
        // 内容
        slivers: <Widget>[
          new SliverPadding(
            padding: const EdgeInsets.all(2.0),
            sliver: SliverList(
              delegate: new SliverChildListDelegate(
                <Widget>[
                  Container(
                    child: Column(
                      children: <Widget>[
                        Container(
                          child: Image.asset("images/love.png"),
                        ),
                        Text(
                          "喜欢您的人",
                          textAlign: TextAlign.center,
                          style: TextStyle(
                            fontSize: 26,
                            fontWeight: FontWeight.w500,
                          ),
                        ),
                        Container(
                          margin: EdgeInsets.only(top: 20, bottom: 40),
                          child: Text(
                            "用Badoo Premium看看那些人觉得您很赞",
                            style: TextStyle(
                              color: Colors.grey,
                              fontSize: 16,
                            ),
                          ),
                        ),
                        Container(
                          height: 60,
                          width: 180,
                          child: Center(
                            child: Text(
                              "解锁我的赞",
                              textAlign: TextAlign.center,
                              style: TextStyle(
                                  color: Colors.white,
                                  fontSize: 20,
                                  fontWeight: FontWeight.w600),
                            ),
                          ),
                          decoration: BoxDecoration(
                              borderRadius:
                                  BorderRadius.all(Radius.circular(18)),
                              color: Colors.deepPurpleAccent),
                        ),
                        Container(
                          margin: EdgeInsets.all(10),
                          padding: EdgeInsets.fromLTRB(2, 2, 0, 4),
                          height: MediaQuery.of(context).size.height *
                              picture.length /
                              5,
                          child: StaggeredGridView.countBuilder(
                            physics: NeverScrollableScrollPhysics(),
                            crossAxisCount: 4,
                            itemCount: picture.length,
                            itemBuilder: (BuildContext context, int index) =>
                                GestureDetector(
                              child: Container(
                                  margin: EdgeInsets.all(2),
                                  child: Container(),
                                  decoration: BoxDecoration(
                                      borderRadius: BorderRadius.circular(10.0),
                                      color: Colors.grey,
                                      image: DecorationImage(
                                          image: NetworkImage(
                                              picture[index]["imageUrl"]),
                                          fit: BoxFit.cover))),
                            ),
                            staggeredTileBuilder: (int index) =>
                                StaggeredTile.count(2, index.isEven ? 2 : 3),
                            mainAxisSpacing: 4.0,
                            crossAxisSpacing: 4.0,
                          ),
                        )

/*

                          StaggeredGridView.countBuilder(
                            crossAxisCount: 4,
                            itemCount: chapterone.length,
                            itemBuilder: (BuildContext context, int index) =>
                                Container(
                                    margin: EdgeInsets.all(2),
                                    child: Container(),
                                    decoration: BoxDecoration(
                                        borderRadius:
                                        BorderRadius.circular(10.0),
                                        color: Colors.grey,
                                        image: DecorationImage(
                                            image: NetworkImage(chapterone[index]["url"]),
                                            fit: BoxFit.cover
                                        )
                                    )),
                            staggeredTileBuilder: (int index) =>
                                StaggeredTile.count(2, index.isEven ? 2 : 3),
                            mainAxisSpacing: 4.0,
                            crossAxisSpacing: 4.0,
                          ),
*/
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}
